/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.game.math.view.action;

import java.awt.event.ActionEvent;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JOptionPane;
import org.game.math.config.Configure;

/**
 *
 * @author nmduc
 */
public class MulTableAction extends AbstractToggleAction {

    public MulTableAction(Configure configure) {
        super(AbstractToggleAction.getResourceBundle().getString("mulTable.menu.name"), configure);
        this.setSelected(configure.isChosenMultiTable());
    }

    @Override
    public void actionPerformed(ActionEvent ae) {
        Configure configure = Configure.getInstance();
        JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
        int multNumber = configure.getChosenMultiNumber();
        if (menuItem.isSelected()) {
            String multNumberTemp = JOptionPane.showInputDialog(menuItem, "Ban muon lam bang cuu chuong may ?",
                    "Chon bang cuu chuong", JOptionPane.QUESTION_MESSAGE);
            multNumber = Integer.parseInt(multNumberTemp);
        }
        configure.setChosenMultiTable(menuItem.isSelected(), multNumber);
    }
}
